package com.oasystem.web.controller.profit;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.oasystem.domain.Member;
import com.oasystem.domain.MemberProfitSearchResult;
import com.oasystem.domain.PagingBean;
import com.oasystem.service.ProfitService;

@Controller
@RequestMapping(value = "/MainMenu/profit")
public class ProfitSearchController {
	@Resource(name = "profitService")
	private ProfitService profitService;

	// search result
	@RequestMapping(value = "/searchResultPage")
	public String searchResultPage(@ModelAttribute("member") Member member,String recordType,
			Model model) {
		PagingBean<MemberProfitSearchResult> pagingBean = new PagingBean<MemberProfitSearchResult>();
		try {
			pagingBean.setCurrentPage(Integer.valueOf(member.getPageIndex()));
			profitService.searchForPagingList(member,recordType, pagingBean);
			model.addAttribute("pagingBean", pagingBean);
			model.addAttribute("member", member);
		} catch (Exception e) {
			e.printStackTrace();
			model.addAttribute("error", e.getMessage());
		}
		return "profit.searchResultPage";
	}

}
